<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    String imgSrc = basePath + "resources/images/noImage.jpg";
    session.setAttribute("imgSrc", imgSrc);
%>
<!DOCTYPE html>
<html style="background-color: #fff;">
<head>
    <%@include file="../../../../resources/inc/head.jsp" %>
</head>
<body>
<expect-x:tip tipMessage="标识“*”的选项为必填项，其余为选填项。;请按提示信息填写每一个字段" widthClass="full-width-85"/>

<div class="layui-form" lay-filter="layuiadmin-form-systemCorn" id="layuiadmin-form-systemCorn"
     style="padding: 20px;">


    <div class="layui-form-item">
        <label class="layui-form-label">品牌名</label>
        <div class="layui-input-block">
            <input type="hidden" name="id" value="${productBrand.id}">
            <input type="text" name="productBrandName" lay-verify="required" value="${productBrand.productBrandName}"
                   placeholder="请输入品牌名" autocomplete="off" class="layui-input">
        </div>
    </div>

    <%--<div class="layui-tab-item layui-show">--%>
        <%--<div class="layui-form-item">--%>
            <%--<label class="layui-form-label">Logo</label>--%>
            <%--<expect-x:webUploader pickerId="productBrandLogo" fileList="${productBrand.productBrandLogo}" isLocal="false" width="140" />--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label">Logo</label>
        <div class="upload-wrapper upload-div " id="layer-photos">
            <div class="upload-item">
                <div class="layui-input-block" style="width: 550px;">
                    <expect-x:webUploader required="true" pickerId="productBrandLogo" isLocal="false" fileList="${productBrand.productBrandLogo}" width="140"/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">官网</label>
        <div class="layui-input-block">
            <input type="text" name="productBrandSiteUrl" lay-verify="required" value="${productBrand.productBrandSiteUrl}"
                   placeholder="请输入官网网址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <%--<textarea  rows="7" cols="85" style="resize:none" name="productBrandDesc" lay-verify="required"--%>
                  <%--value="${productBrand.productBrandDesc}" placeholder="${productBrand.productBrandDesc==null?'请输入描述':''}">${productBrand.productBrandDesc}</textarea>--%>
        <div class="layui-input-block">
            <textarea   placeholder="请输入" style="resize:none" name="productBrandDesc" class="layui-textarea">${productBrand.productBrandDesc}</textarea>
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>

<%@include file="../../../../resources/inc/footer.jsp" %>

<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$
            , form = layui.form
    })

    function createSubmit() {
        var layer = layui.layer;
        var submitID = 'LAY-submit';
        layui.form.on('submit(' + submitID + ')', function (data) {
            var formData = data.field;
            if (formData.id == "" || formData.id == null) {
                delete formData["id"];
                $.ajax({
                    url: '<%=basePath%>manager/productBrand/create.html',
                    type: "POST",
                    data: formData,
                    dataType: "JSON",
                    success: function (data) {
                        layer.closeAll('loading');
                        if (data.success) {
                            layer.msg("创建成功,1秒后跳转")
                            setTimeout(function () {
                                window.parent.location.reload(); //刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }, 1000);
                        } else {
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            } else {
                $.ajax({
                    url: "<%=basePath%>manager/productBrand/update/" + formData.id + ".html",
                    type: "POST",
                    data: formData,
                    dataType: "JSON",
                    success: function (data) {
                        layer.closeAll('loading');
                        if (data.success) {
                            layer.msg("修改成功,1秒后跳转");
                            setTimeout(function () {
                                window.parent.location.reload(); //刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }, 1000);
                        } else {
                            layer.msg(data.message, {icon: 5});
                        }
                    }
                });
            }
        })
        $("#" + submitID).trigger('click');
    }
</script>
</body>
</html>
